﻿//-----------------------------------------------------------------------
// <copyright file="TickersWindow.xaml.cs" company="AFS">
// Copyright (c) AFS. All rights reserved.
//
//    This file is part of Chatbox.
//
//    Chatbox is free software: you can redistribute it and/or modify
//    it under the terms of the GNU Lesser General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    any later version.
//
//    Chatbox is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//    GNU Lesser General Public License for more details.
//
//    You should have received a copy of the GNU Lesser General Public License
//    along with Chatbox. If not, see http://www.gnu.org/copyleft/lesser.html
// </copyright>
//----------------------------------------------------------------------- 

namespace ChatBox.UI.Windows.Tickers
{
    using System;
    using System.ComponentModel;
    using System.Windows;

    /// <summary>
    /// Window to show the various activity tickers - new nodes, newly cooled nodes, etc
    /// </summary>
    public partial class TickersWindow : Window
    {
        /// <summary>
        /// Initializes a new instance of the TickersWindow class
        /// </summary>
        public TickersWindow()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Gets the viewModel for this form
        /// </summary>
        public TickersViewModel ViewModel
        {
            get
            {
                return this.DataContext as TickersViewModel;
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether to hide or actually close
        /// </summary>
        public bool HideOnClose
        {
            get;
            set;
        }

        /// <summary>
        /// Window closing event
        /// </summary>
        /// <param name="sender">the event sender</param>
        /// <param name="e">the event params</param>
        private void Window_Closing(object sender, CancelEventArgs e)
        {
            if (this.HideOnClose)
            {
                this.Visibility = Visibility.Collapsed;
                e.Cancel = true;
            }
        }

        /// <summary>
        /// Window closed event handler
        /// </summary>
        /// <param name="sender">the event sender</param>
        /// <param name="e">the event params</param>
        private void Window_Closed(object sender, EventArgs e)
        {
            this.ViewModel.SaveWindowPosition();
        }
    }
}
